/*
 This file is part of ParagliderDesk.
 Copyright (C) 2009 Benjamin Loulier 
 
 ParagliderDeck is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 ParagliderDesk is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with ParagliderDesk.  If not, see <http://www.gnu.org/licenses/>.
 
 File: CLController.h
 
 Abstract: Singleton class used to talk to CoreLocation and send results back to
 the app's view controllers.
 
 Version: 0.1
 
 TODO LIST :
 - look nonatomic, retain
 - use of NSDecimalNumber
 - Make a new class heritating (or delegating) CLLocation with one variable more (vertical speed).
 - Find a better solution to calculate vSpeed and Glide Ration (redundant code)
 */

#import "Location.h"

// This protocol is used to send the text for location updates back to another view controller
@protocol CLControllerDelegate <NSObject>
@required
-(void)newLocationUpdate;
-(void)newError:(NSString *)text;
@end


// Class definition
@interface CLController : NSObject <CLLocationManagerDelegate> {
	CLLocationManager *locationManager;
	//delegate
	id delegate;
	//Logger
	id logger;
	//Variables to handle fix
	BOOL twoDFix;
	BOOL threeDFix;
	//Variable which give the time elapsed between two valid measures
	NSTimeInterval timeElapsed;
	//Store four positions
	NSMutableArray *locationHistoric;
}

@property BOOL twoDFix, threeDFix;
@property NSTimeInterval timeElapsed;
@property (nonatomic, retain) CLLocationManager *locationManager;
@property (nonatomic,assign) id <CLControllerDelegate> delegate, logger;
@property (nonatomic, retain) NSMutableArray *locationHistoric;


- (void)locationManager:(CLLocationManager *)manager
	didUpdateToLocation:(CLLocation *)newLocation
		   fromLocation:(CLLocation *)oldLocation;

- (void)locationManager:(CLLocationManager *)manager
	   didFailWithError:(NSError *)error;

+ (CLController *)sharedInstance;

@end

